import {defineStore} from 'pinia'
import {Permission} from "@utils/resource";
import util from "@utils/util";

export const permissionStore = defineStore({
    id: 'permission',
    state: () => ({
        queryParams: {
            name: null,
            sortColumn: "created desc",
        },
        permissionsTree: [],
        permissionsArray: [],
    }),
    getters: {},
    actions: {
        async loadPermissions() {
            let res = await Permission.tree()
            this.permissionsTree = res.data
            this.permissionsArray = util.treeToArray(this.permissionsTree)
        },
    }
})
